package com.itheima.anno;

import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.*;
import org.springframework.stereotype.Component;

/**
 * @author 17976
 */
@Component("MyAspect")
@Aspect
public class MyAspect {

//    @Before("execution(* com.itheima.anno.*.*(..))")
    public void before(){
        System.out.println("前置增强");
    }
    public void afterReturning(){
        System.out.println("后置增强");
    }
//   @Around("execution(* com.itheima.anno.*.*(..))")
    @Around("pointcut()")
    public Object around(ProceedingJoinPoint pjp) throws Throwable {
        System.out.println("环绕前增强");
        Object proceed = pjp.proceed();
        System.out.println("环绕后增强");
        return proceed;
    }
    public void afterThrowing(){
        System.out.println("异常抛出增强");
    }
//    @After("execution(* com.itheima.anno.*.*(..))")
    @After("MyAspect.pointcut()")
    public void after(){
        System.out.println("最终增强");
    }
    @Pointcut("execution(* com.itheima.anno.*.*(..))")
    public void pointcut(){
        System.out.println("切点方法");
    }

}
